<template>
  <div class="baseinfo" v-title data-title="信息化项目立项界面">
    <div v-if="!isOld">
      <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item label="项目编号" prop="projectNo" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              {{ form.projectNo }}
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item ref="projectName" label="项目名称" prop="projectName" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-input v-model="form.projectName" @blur="
                () => {
                  $refs.projectName.onFieldBlur()
                }
              " placeholder="请输入有效的项目名称" :disabled="form.status > 1" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目分类" prop="projectTypeSubCategory" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-select v-model="form.projectTypeSubCategory" placeholder="请选择项目分类" :options="projectCategoryOptions" :disabled="form.id != ''" style="width: 50%" @change="projectTypeChange">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
              <a-select v-model="form.projectLevel" v-if="!form.status||form.status==1" placeholder="请选择项目等级" style="width: 50%" :options="projectLevelOptions">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
              <a-select v-model="form.projectAuditLevel" v-else placeholder="请选择项目等级" style="width: 50%" :options="projectLevelOptions">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="8">
<!--            <span class="selectTip" v-show="form.resultOperationPlan === '1'">温馨提示：项目属于对外运营的，注意需要在正式上线前完成商标和软件著作权的获取工作</span>-->
            <a-form-model-item label="运营计划" prop="resultOperationPlan" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-select v-model="form.resultOperationPlan" placeholder="请选择" :options="resultOperationPlanOptions">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="代码情况" prop="codeSafety" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-select v-model="form.codeSafety" placeholder="请选择" :options="codeSafetyOptions">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item ref="deptCost" label="项目金额" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-input-number v-model="form.deptCost" :min="0" placeholder="请填写项目金额" style="width: 100%"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item label="项目概述" prop="projectContent" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-textarea v-model="form.projectContent " placeholder="请输入项目概述" :rows="4" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item label="项目范围" prop="projectUseFor" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-textarea v-model="form.projectUseFor " placeholder="请输入项目范围" :rows="4" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item label="交付要求" prop="projectImplement" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-textarea v-model="form.projectImplement " placeholder="请输入项目交付要求" :rows="4" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <five-to-five ref="fiveForm" :projectBuildId="projectBuildId" :change-id="changeId" @addField="addFiveDataToForm"/>
      </a-form-model>
    </div>

    <div v-if="isOld">
      <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item label="项目编号" prop="projectNo" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              {{ form.projectNo }}
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item ref="projectName" label="项目名称" prop="projectName" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-input v-model="form.projectName" @blur="
                () => {
                  $refs.projectName.onFieldBlur()
                }
              " placeholder="请输入有效的项目名称" :disabled="form.status > 1" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="项目分类" prop="projectTypeSubCategory" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-select v-model="form.projectTypeSubCategory" placeholder="请选择项目分类" :options="projectCategoryOptions" :disabled="form.id != ''">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row :gutter="24">
          <a-col :span="8">
<!--            <span class="selectTip" v-show="form.resultOperationPlan === '1'">温馨提示：项目属于对外运营的，注意需要在正式上线前完成商标和软件著作权的获取工作</span>-->
            <a-form-model-item label="项目成果运营计划" prop="resultOperationPlan" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-select v-model="form.resultOperationPlan" placeholder="请选择" :options="resultOperationPlanOptions">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="源代码计划安全措施" prop="codeSafety" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-select v-model="form.codeSafety" placeholder="请选择" :options="codeSafetyOptions">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item ref="hatchProjectNo" label="项目人天" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-input v-model="form.projectManDays" type="number" min="0" max="100000" placeholder="请填写项目人天" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <!-- <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item
              label="源代码计划安全措施"
              prop="codeSafety"
              :label-col="{ span: 3 }"
              :wrapper-col="{ span: 21 }"
            >
              <a-select
                v-model="form.codeSafety"
                placeholder="请选择"
                :options="codeSafetyOptions"
              >
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row> -->
        <!-- <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item
              ref="projectUseFor"
              label="项目范围确定"
              prop="projectUseFor"
              :label-col="{ span: 3 }"
              :wrapper-col="{ span: 21 }"
            >
              <a-textarea
                v-model="form.projectUseFor"
                @blur="
                  () => {
                    $refs.projectUseFor.onFieldBlur()
                  }
                "
                :auto-size="{ minRows: 3, maxRows: 5 }"
                style="width: 100%"
                placeholder="请清晰描述本期项目所含的实施范围"
              />
            </a-form-model-item>
          </a-col>
        </a-row> -->
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item ref="projectContent" label="项目内容概述" prop="projectContent" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }">
              <a-textarea v-model="form.projectContent" @blur="
                () => {
                  $refs.projectContent.onFieldBlur()
                }
              " :auto-size="{ minRows: 3, maxRows: 5 }" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="业务参与情况" prop="businessJoin" :label-col="{ span: 8 }" :wrapper-col="{ span: 15 }">
              <a-select v-model="form.businessJoin" placeholder="请选择" :options="businessJoinOptions">
                <a-icon slot="suffixIcon" type="plus" />
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
        <div>
          <h3 style="margin-top:10px;"><b>业务应用范围</b></h3>
          <div style="display: flex; margin-top: 10px; margin-bottom: 10px" v-show="btnShow">
            <a-button type="primary" @click="businessAdd()">新增</a-button>
            <a-button style="margin-right: 15px" class="default" @click="businessDel()">删除</a-button>
          </div>
          <a-table :row-selection="businessUsedForRowSelection" :columns="businessUsedFor.columns" :data-source="businessUsedFor.data" bordered :key="businessUsedFor.businessFreshKey">
            <template slot="kpiDescribe" slot-scope="text, record">
              <a-textarea v-model="record.kpiDescribe" placeholder="500字以内" :auto-size="{ minRows: 1, maxRows: 10 }" :maxLength="500" />
            </template>
            <template slot="kpiTarget" slot-scope="text, record">
              <a-textarea v-model="record.kpiTarget" placeholder="500字以内" :auto-size="{ minRows: 1, maxRows: 10 }" :maxLength="500" />
            </template>
          </a-table>
        </div>
        <div>
          <h3 style="margin-top:10px;"><b>技术应用范围</b></h3>
          <div style="display: flex; margin-top: 10px; margin-bottom: 10px" v-show="btnShow">
            <a-button type="primary" @click="techAdd()">新增</a-button>
            <a-button style="margin-right: 15px" class="default" @click="techDel()">删除</a-button>
          </div>
          <a-table :row-selection="techUsedForRowSelection" :columns="techUsedFor.columns" :data-source="techUsedFor.data" bordered :key="techUsedFor.techFreshKey">
            <template slot="kpiDescribe" slot-scope="text, record">
              <a-textarea v-model="record.kpiDescribe" placeholder="500字以内" :auto-size="{ minRows: 1, maxRows: 10 }" :maxLength="500" />
            </template>
            <template slot="kpiTarget" slot-scope="text, record">
              <a-textarea v-model="record.kpiTarget" placeholder="500字以内" :auto-size="{ minRows: 1, maxRows: 10 }" :maxLength="500" />
            </template>
          </a-table>
        </div>
        <div>
          <h3 style="margin-top:10px;"><b>业务KPI</b></h3>
          <div style="display: flex; margin-top: 10px; margin-bottom: 10px" v-show="btnShow">
            <a-button type="primary" @click="kpiAdd()">新增</a-button>
            <a-button style="margin-right: 15px" class="default" @click="kpiDel()">删除</a-button>
          </div>
          <a-table :row-selection="rowSelection" :columns="kpi.columns" :data-source="kpi.data" bordered :key="kpi.freshKey">
            <template slot="kpiDescribe" slot-scope="text, record">
              <a-textarea v-model="record.kpiDescribe" placeholder="50字以内" :auto-size="{ minRows: 1, maxRows: 10 }" :maxLength="50" />
            </template>
            <template slot="kpiTarget" slot-scope="text, record">
              <a-textarea v-model="record.kpiTarget" placeholder="500字以内" :auto-size="{ minRows: 1, maxRows: 10 }" :maxLength="500" />
            </template>
            <template slot="kpiExplain" slot-scope="text, record">
              <a-textarea v-model="record.kpiExplain" placeholder="500字以内" :auto-size="{ minRows: 1, maxRows: 10 }" :maxLength="500" />
            </template>
          </a-table>
        </div>
        <five-to-five ref="fiveForm" :projectBuildId="projectBuildId" :change-id="changeId" @addField="addFiveDataToForm"/>
      </a-form-model>
    </div>
  </div>
</template>
<script>
import $ from 'jquery'
import { getAction, getActionAsync, postAction, postActionAsync } from '@/api/manage'
import { getParamValFromUrl, strNotNull } from '@/utils/common.js'
import { Modal } from 'ant-design-vue'
import Vue from 'vue'

export default {
  components: {
    PaginationSelect: () => import('@/components/tools/PaginationSelect'),
    FiveToFive: () => import('@/components/tools/projectBuildStup/baseInfo/FiveToFive')
  },
  props: {
    projectBuildId: {
      Type: String,
      default: '',
    },
    isOld:{
      type: Boolean ,
      default : true
    } ,
    changeId: {
      Type: String,
      default: '',
    },
  },
  data () {
    return {
      kpi: {
        columns: [
          {
            title: '序号',
            dataIndex: 'index',
            key: 'index',
            align: 'center',
            width: 100,
            customRender: (text,record,index) => `${index+1}`,
          },
          {
            title: 'kpi描述',
            dataIndex: 'kpiDescribe',
            width: '30%',
            scopedSlots: { customRender: 'kpiDescribe' },
          },
          {
            title: '达成目标',
            dataIndex: 'kpiTarget',
            width: '30%',
            scopedSlots: { customRender: 'kpiTarget' },
          },
          {
            title: '说明',
            dataIndex: 'kpiExplain',
            scopedSlots: { customRender: 'kpiExplain' },
          },
        ],
        data: [],
        selRowIds: [],
        freshKey: 0,
      },
      businessUsedFor: {
        columns: [
          {
            title: '序号',
            dataIndex: 'index',
            key: 'index',
            align: 'center',
            width: 100,
            customRender: (text,record,index) => `${index+1}`,
          },
          {
            title: '功能\\流程',
            dataIndex: 'kpiDescribe',
            width: '30%',
            scopedSlots: { customRender: 'kpiDescribe' },
          },
          {
            title: '应用说明',
            dataIndex: 'kpiTarget',
            scopedSlots: { customRender: 'kpiTarget' },
          }
        ],
        data: [],
        selRowIds: [],
        businessFreshKey: 0,
      },
      techUsedFor: {
        columns: [
          {
            title: '序号',
            dataIndex: 'index',
            key: 'index',
            align: 'center',
            width: 100,
            customRender: (text,record,index) => `${index+1}`,
          },
          {
            title: '技术\\功能',
            dataIndex: 'kpiDescribe',
            width: '30%',
            scopedSlots: { customRender: 'kpiDescribe' },
          },
          {
            title: '应用说明',
            dataIndex: 'kpiTarget',
            scopedSlots: { customRender: 'kpiTarget' },
          }
        ],
        data: [],
        selRowIds: [],
        techFreshKey: 0,
      },
      labelCol: { span: 8 },
      wrapperCol: { span: 15 },
      other: '',
      form: {
        id: '',
        projectClass: '30',
        projectNo: '',
        projectName: '',
        projectManDays: 0,
        projectTypeSubCategory: '',
        projectContent: '',
        projectUseFor: '',
        projectImplement:'',
        resultOperationPlan: undefined,
        codeSafety: undefined,
        projectBuildKpiVOList: [],
        status: 0,
      },
      rules: {
        projectName: [
          { required: true, message: '请输入有效的项目名', trigger: 'blur' },
          { min: 1, max: 50, message: '项目名不超过50个字符', trigger: 'blur' },
        ],
        projectTypeSubCategory: [{ required: true, message: '请选择项目分类', trigger: 'change' }],
        projectManDays: [{ required: true, message: '请输入项目人天', trigger: 'blur' }],
        projectContent: [
          { required: true, message: '请输入项目概述', trigger: 'blur' },
          { min: 1, max: 2000, message: '项目概述不超过2000个字符', trigger: 'blur' },
        ],
        projectUseFor: [
          { required: true, message: '请输入项目范围', trigger: 'blur' },
          { min: 1, max: 2000, message: '项目范围不能为空', trigger: 'blur' },
        ],
        projectImplement: [
          { required: true, message: '请输入交付要求', trigger: 'blur' },
          { min: 1, max: 2000, message: '交付要求不能为空', trigger: 'blur' },
        ],
        resultOperationPlan: [{ required: true, message: '请选择项目成果是否有对外运营计划', trigger: 'change' }] ,

      },
      projectCategoryOptions: [],
      projectLevelOptions: [],
      resultOperationPlanOptions: [],
      codeSafetyOptions: [],
      businessJoinOptions: [],
      url: {
        codeInfoList: '/manage/codeInfo/list',
        getProjectByNo: '/projectBuild/getProjectByNo',
        save: '/projectBuild/add',
        queryVOById: '/projectBuild/queryVOById',
      },
      loadFinish: false,
      btnShow: false,
      canDoSave: this.$route.query.canDoSave ? (this.$route.query.canDoSave=='true' ? true : false) : true,
    }
  },
  computed: {
    rowSelection () {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
          this.kpi.selRowIds = selectedRowKeys
        },
      }
    },
    businessUsedForRowSelection () {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
          this.businessUsedFor.selRowIds = selectedRowKeys
        },
      }
    },
    techUsedForRowSelection () {
      return {
        onChange: (selectedRowKeys, selectedRows) => {
          this.techUsedFor.selRowIds = selectedRowKeys
        },
      }
    },
  },
  methods: {
     addFiveDataToForm(val,valRef) {
      this.$set(this.form, valRef, val)
    },
    async doSubmit () {
      if (!this.loadFinish) {
        layer.message.warning('请等待页面加载完毕')
        return {}
      }
      var validR = false
      try {
        validR = await this.$refs.ruleForm.validate()
        validR = await this.$refs.fiveForm.checkFiveWriteStatus()
      } catch (e) {
        validR = false
      }
      console.log('validR', validR)
      this.form.validResult = validR
      let res = await this.doSave()
      return { valid: validR, id: res }
    },
    async doSave () {
      let flag = null
      let arr = []
      if(!this.form.projectLevel){
        return  this.$message.warning('请选择项目等级')
      }
      this.form.projectBuildKpiVOList = arr.concat(this.kpi.data,this.businessUsedFor.data,this.techUsedFor.data)

      this.form.changeId = this.changeId
      var vm = this
      await postActionAsync(this.url.save, this.form)
        .then((res) => {
          if (res.code == 200) {
            vm.form.id = res.result.id
            vm.form.projectNo = res.result.projectNo
            this.$message.success('保存成功')
            this.initData()
            return (flag = res.result.id)
          } else {
            this.$message.warning('保存数据出错:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('保存数据出错:' + res.message)
        })
      return flag
    },
    resetForm () {
      this.$refs.ruleForm.resetFields()
    },
    //初始化项目子类
    initProjectCategoryOptions () {
      var vm = this
      getAction(this.url.codeInfoList, { type: '项目子类', isdel: 0, parentid: vm.form.projectClass })
        .then((res) => {
          if (res.code == 200) {
            var list = res.result
            if (list != null) {
              list.records.map((item) => {
                vm.projectCategoryOptions.push({ value: item.code, label: item.name })
              })
            }
          } else {
            this.$message.warning('查询项目子类失败:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('查询项目子类失败:' + res.message)
        })
    },

    //如果有id，则加载已填写信息
    initData () {
      if (this.projectBuildId != null && this.projectBuildId != '') {
        var vm = this
        getAction(this.url.queryVOById, { id: this.projectBuildId, changeId: this.changeId })
          .then((res) => {
            if (res.code == 200) {
              var result = res.result
              if (result != null) {
                this.form = result
                if (result.projectBuildKpiVOList != null) {
                  this.kpi.data = result.projectBuildKpiVOList.filter(item => !item.baseType)
                  this.kpi.data.forEach((item) => {
                    item.key = item.strId
                  })
                  this.businessUsedFor.data = result.projectBuildKpiVOList.filter(item => item.baseType && item.baseType == 1)
                  this.businessUsedFor.data.forEach((item) => {
                    item.key = item.strId
                  })
                  this.techUsedFor.data = result.projectBuildKpiVOList.filter(item => item.baseType && item.baseType == 2)
                  this.techUsedFor.data.forEach((item) => {
                    item.key = item.strId
                  })
                }
                this.projectTypeChange();
                this.loadFinish = true
              } else {
                vm.$message.warning('初始化项目信息为空')
              }
            } else {
              this.$message.warning('初始化项目信息失败:' + res.message)
            }
          })
          .catch((res) => {
            this.$message.warning('初始化项目信息失败:' + res.message)
          })
      } else {
        this.loadFinish = true;
      }
    },
    kpiAdd () {
      this.kpi.data.push({
        key: this.kpi.data.length + 1 + new Date().getTime(),
        strId: '',
        kpiDescribe: '',
        kpiTarget: '',
        kpiExplain: '',
      })
    },
    kpiDel () {
      if (this.kpi.selRowIds.length == 0) {
        this.$message.warning('请选择要删除的kpi记录')
        return
      }
      var vm = this;
      Modal.confirm({
        title: '警告',
        content: '真的要删除吗?',
        okText: '删除',
        okType: 'danger',
        cancelText: '取消',
        onOk () {
          console.log('OK')
          // 在这里调用删除接口
          for (var i = 0; i < vm.kpi.selRowIds.length; i++) {
            for (var j = vm.kpi.data.length - 1; j >= 0; j--) {
              if (vm.kpi.data[j].key == vm.kpi.selRowIds[i]) {
                vm.kpi.data.splice(j, 1)
                break
              }
            }
          }
          vm.kpi.selRowIds = []
          vm.kpi.freshKey++
        },
        onCancel () {
          console.log('Cancel')
        },
      })
    },
    businessAdd () {
      this.businessUsedFor.data.push({
        key: this.businessUsedFor.data.length + 1 + new Date().getTime(),
        strId: '',
        kpiDescribe: '',
        kpiTarget: '',
        kpiExplain: '',
        baseType: 1
      })
    },
    businessDel () {
      if (this.businessUsedFor.selRowIds.length == 0) {
        this.$message.warning('请选择要删除的业务应用范围记录')
        return
      }
      var vm = this;
      Modal.confirm({
        title: '警告',
        content: '真的要删除吗?',
        okText: '删除',
        okType: 'danger',
        cancelText: '取消',
        onOk () {
          // 在这里调用删除接口
          for (var i = 0; i < vm.businessUsedFor.selRowIds.length; i++) {
            for (var j = vm.businessUsedFor.data.length - 1; j >= 0; j--) {
              if (vm.businessUsedFor.data[j].key == vm.businessUsedFor.selRowIds[i]) {
                vm.businessUsedFor.data.splice(j, 1)
                break
              }
            }
          }
          vm.businessUsedFor.selRowIds = []
          vm.businessUsedFor.businessFreshKey++
        },
        onCancel () {
          console.log('Cancel')
        },
      })
    },
    techAdd () {
      this.techUsedFor.data.push({
        key: this.techUsedFor.data.length + 1 + new Date().getTime(),
        strId: '',
        kpiDescribe: '',
        kpiTarget: '',
        kpiExplain: '',
        baseType: 2
      })
    },
    techDel () {
      if (this.techUsedFor.selRowIds.length == 0) {
        this.$message.warning('请选择要删除的技术应用范围记录')
        return
      }
      var vm = this;
      Modal.confirm({
        title: '警告',
        content: '真的要删除吗?',
        okText: '删除',
        okType: 'danger',
        cancelText: '取消',
        onOk () {
          // 在这里调用删除接口
          for (var i = 0; i < vm.techUsedFor.selRowIds.length; i++) {
            for (var j = vm.techUsedFor.data.length - 1; j >= 0; j--) {
              if (vm.techUsedFor.data[j].key == vm.techUsedFor.selRowIds[i]) {
                vm.techUsedFor.data.splice(j, 1)
                break
              }
            }
          }
          vm.techUsedFor.selRowIds = []
          vm.techUsedFor.techFreshKey++
        },
        onCancel () {
          console.log('Cancel')
        },
      })
    },
    initCodeInfo () {
      var vm = this
      getAction(this.url.codeInfoList, { type: '信息化项目成果是否有对外运营计划', isdel: 0, pageSize: -1 })
        .then((res) => {
          if (res.code == 200) {
            var list = res.result
            if (list != null) {
              list.records.map((item) => {
                vm.resultOperationPlanOptions.push({ value: item.code, label: item.name })
              })
            }
          } else {
            this.$message.warning('查询信息化项目成果是否有对外运营计划失败:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('查询信息化项目成果是否有对外运营计划失败:' + res.message)
        })

      getAction(this.url.codeInfoList, { type: '软件源代码的计划安全措施', isdel: 0, pageSize: -1 })
        .then((res) => {
          if (res.code == 200) {
            var list = res.result
            if (list != null) {
              list.records.map((item) => {
                vm.codeSafetyOptions.push({ value: item.code, label: item.name })
              })
            }
          } else {
            this.$message.warning('查询软件源代码的计划安全措施失败:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('查询软件源代码的计划安全措施失败:' + res.message)
        })
      getAction(this.url.codeInfoList, { type: '信息化业务参与情况', isdel: 0, pageSize: -1 })
        .then((res) => {
          if (res.code == 200) {
            let list = res.result||[];
            if (list != null) {
              list.records.map((item) => {
                vm.businessJoinOptions.push({ value: item.code, label: item.name })
              })
            }
          } else {
            this.$message.warning('查询信息化业务参与情况失败:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('查询信息化业务参与情况失败:' + res.message)
        })
    },
    businessJoinChange(value,option){
      this.form.businessJoinDes=option.componentOptions.children[0].text;
    },
    projectTypeChange(){
      let projectType=this.form.projectTypeSubCategory;
      if(!this.form.status||this.form.status==1){
        // this.$set(this.form,"projectLevel",'');
        // this.form.projectLevel='';
      }else{
        // this.$set(this.form,"projectLevel",'');
        // this.form.projectAuditLevel='';
      }
      this.projectLevelOptions=[];
      this.projectLevelOptions.push({ value: "", label: "请选择项目等级" });
      this.projectLevelOptions.push({ value: projectType+"1", label: projectType+"1" });
      this.projectLevelOptions.push({ value: projectType+"2", label: projectType+"2" });
      this.projectLevelOptions.push({ value: projectType+"3", label: projectType+"3" });
      this.projectLevelOptions.push({ value: projectType+"4", label: projectType+"4" });
      this.projectLevelOptions.push({ value: projectType+"X", label: projectType+"X" });
    },
  },
  mounted () {
    this.initProjectCategoryOptions()
    this.initCodeInfo()
    this.initData()
    this.btnShow=this.canDoSave;
  },
}
</script>
<style lang="less" scoped>
.editable-row-operations a {
  margin-right: 8px;
}
/deep/ .ant-btn-primary {
  width: 85px;
  height: 30px;
  border-radius: 2px;
  background: #4095e4;
  margin-right: 10px;
}
/deep/ .default {
  width: 85px;
  height: 30px;
  border-radius: 2px;
}
.baseinfo {
  background-color: #fff;
  border: 1px solid #eaeaea;
  height: fit-content;
  padding: 30px;
  .btn {
    display: flex;
    justify-content: center;
  }
}
.selectTip {
  font-size: 16px;
  font-weight: bold;
  color: red;
}
</style>